package com.demo.junit;

import org.junit.Before;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import redis.clients.jedis.Jedis;

@SpringBootTest
public class JedisTester {

    private Jedis jedis;

    @Before
    public void setup(){
        //连接redis服务器，127.0.0.1:6379
        jedis = new Jedis("192.168.33.128",6379);
        //权限认证，指定密码
        jedis.auth("021210");
    }

   /* @Test
    public void testString(){
        //-----添加数据----------
        jedis.set("name","ktjiaoyu");   //向key-->name中放入了value-->ktjiaoyu
        System.out.println(jedis.get("name")); //执行结果：ktjiaoyu

        jedis.append("name","czkt");    //拼接
        System.out.println(jedis.get("name"));

        jedis.del("name");  //删除某个键
        System.out.println(jedis.get("name"));
        //设置多个键值对
        jedis.mset("name","ktjiaoyu","age","17","add","cz");
        jedis.incr("age");  //进行加1操作
        System.out.println(jedis.get("name") + "-" + jedis.get("age") + "-" + jedis.get("add"));
    }*/
}
